import { log } from "console";

const express = require('express');
const router = express.Router();
const fs = require('fs')
const path = require('path')
const ffmpeg = require('ffmpeg')
const FileName="uploads/"

//获取具体文件
router.post('/convert', (req, res) => {
  console.log(req.body)
  const {path,name} = req.body
  const process = new ffmpeg(`${FileName}私奔到月球.m4a`);

  process.then((video) => {
    console.log(video)
    video.fnExtractSoundToMP3(`${FileName}私奔到月球.mp3`, (error, file) => {
      if (!error) {
        res.json("ok")
      } else {

        res.json({
          code: 500,
          error
        })
      }

    })
  })
    .catch(err => {
      res.json("err")
  })

  
})





export default  router;